package com.svms.service.mapper;

import java.util.Date;

import com.svms.model.SvmsSpareStatic;
import com.svms.service.vo.SpareCodesVO;

public class SpareCodeMapper {

	public static SvmsSpareStatic serviceToDml(SpareCodesVO spareCodesVO) {

		SvmsSpareStatic svmsSpareStatic = new SvmsSpareStatic();
		svmsSpareStatic.setSpareId(Long.valueOf(spareCodesVO.getSpareId()));
		svmsSpareStatic.setSpareName(spareCodesVO.getSpareName());
		svmsSpareStatic.setValidationFormat(spareCodesVO.getValidationFormat());
		svmsSpareStatic.setMaxlifeTimeInDt(spareCodesVO.getMaxDays());
		svmsSpareStatic.setCutoffTimeInDt(spareCodesVO.getCutOffDays());
		svmsSpareStatic.setMaxlifeTimeInKm(spareCodesVO.getMaxDistance());
		svmsSpareStatic.setCutoffTimeInKm(spareCodesVO.getCutOffDistance());
		svmsSpareStatic.setCreateTime(new Date());
		svmsSpareStatic.setUpdateBy("om39a");
		svmsSpareStatic.setUpdatedTime(new Date());

		return svmsSpareStatic;
	}

	public static SpareCodesVO dmlToService(SvmsSpareStatic svmsSpareStatic) {

		SpareCodesVO spareCodesVO = new SpareCodesVO();
		spareCodesVO.setSpareId(String.valueOf(svmsSpareStatic.getSpareId()));
		spareCodesVO.setSpareName(svmsSpareStatic.getSpareName());
		spareCodesVO.setValidationFormat(svmsSpareStatic.getValidationFormat());
		spareCodesVO.setMaxDays(svmsSpareStatic.getMaxlifeTimeInDt());
		spareCodesVO.setCutOffDays(svmsSpareStatic.getCutoffTimeInDt());
		spareCodesVO.setMaxDistance(svmsSpareStatic.getMaxlifeTimeInKm());
		spareCodesVO.setCutOffDistance(svmsSpareStatic.getCutoffTimeInKm());

		return spareCodesVO;

	}
}
